// $Id: types.hpp 2 2009-09-02 08:47:42Z joseph2002 $
/*
 * Copyright 2008-2009 Joseph Wu
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
 *
 * For more information, see http://xpcomplus.sourceforge.net
 */

#ifndef XPCOM_TYPES_HPP
#define XPCOM_TYPES_HPP

#include <xpcom/config.hpp>
#include <cstddef>
#include <boost/cstdint.hpp>

#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif

namespace xpcom {

//
// Basic types
//
using boost::int8_t;
using boost::uint8_t;
using boost::int16_t;
using boost::uint16_t;
using boost::int32_t;
using boost::uint32_t;

#ifndef BOOST_NO_INT64_T
using boost::int64_t;
using boost::uint64_t;
#else // BOOST_NO_INT64_T
struct int64_t {
#ifdef XPCOM_LITTLE_ENDIAN
    uint32_t lo, hi;
#else
    uint32_t hi, lo;
#endif
};
typedef int64_t uint64_t;
#endif // BOOST_NO_INT64_T

typedef int32_t         offset32_t;
typedef int64_t         offset64_t;

typedef int             int_t;
typedef unsigned int    uint_t;
typedef std::size_t     size_t;
typedef int_t           bool_t;
typedef int8_t          pbool_t;

const bool_t  true_     = 1;
const bool_t  false_    = 0;
const pbool_t ptrue_    = 1;
const pbool_t pfalse_   = 0;

//
// UTF-16 and UCS4 character type in platform native endian
//
#if defined(XPCOM_HAS_2BYTE_WCHAR_T)
typedef wchar_t wchar;
typedef uint32_t unichar;
#elif defined(XPCOM_HAS_4BYTE_WCHAR_T)
typedef uint16_t wchar;
typedef wchar_t unichar;
#else
typedef uint16_t wchar;
typedef uint32_t unichar;
#endif

//
// XPCOM result data type
//
typedef uint32_t result_t;

//
// XPCOM reference count value type
//
#if defined(XPCOM_PLATFORM_WIN32) && ULONG_MAX == 0xFFFFFFFF
typedef unsigned long refcnt_t;
#else
typedef uint32_t refcnt_t;
#endif

//
// Forward declarations of XPCOM UUID type
//
class uuid;

//
// Forward declarations of XPCOM string types
//
template <typename CharT>
class XPCOM_DECL basic_string; // XXX XPCOM_DECL here can get rid of MSVC:C4251

typedef basic_string<char> string;
typedef basic_string<wchar> wstring;

class ustring;

//
// Forward declarations of XPCOM interface
//

// Some compiler defined 'interface'...
#ifdef interface
#  undef interface
#endif

class interface;

} // namespace xpcom

#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif

#endif // XPCOM_TYPES_HPP
